<?php

/**
 * This is the model class for table "{{edu_term}}".
 *
 * The followings are the available columns in table '{{edu_term}}':
 * @property double $term_id
 * @property double $term_start_year
 * @property double $term_end_year
 * @property string $term_type
 * @property string $term_start_date
 * @property string $term_end_date
 */
class EduTerm extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return EduTerm the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{edu_term}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('term_start_year, term_end_year', 'numerical'),
			array('term_type', 'length', 'max'=>7),
			array('term_start_date, term_end_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('term_id, term_start_year, term_end_year, term_type, term_start_date, term_end_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'term_id' => 'Term',
			'term_start_year' => 'Term Start Year',
			'term_end_year' => 'Term End Year',
			'term_type' => 'Term Type',
			'term_start_date' => 'Term Start Date',
			'term_end_date' => 'Term End Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('term_id',$this->term_id);
		$criteria->compare('term_start_year',$this->term_start_year);
		$criteria->compare('term_end_year',$this->term_end_year);
		$criteria->compare('term_type',$this->term_type,true);
		$criteria->compare('term_start_date',$this->term_start_date,true);
		$criteria->compare('term_end_date',$this->term_end_date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}